<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta th:include="common/commons :: layui"/>
    <title>好友上限</title>
    <style type="text/css">
        .layui-form-pane .layui-form-label {
            width: 200px;
        }

        .layui-form-pane .layui-input-block {
            margin-left: 200px;
        }

        .layui-table-fixed-r td {
            height: 68px !important;
        }

        .layui-table-fixed-r th {
            height: 68px !important;
        }

        .layui-table img {
            max-width: 68px;
            min-height: 68px;
        }

        .laytable-cell-3-wx_headimg, .laytable-cell-1-wx_headimg, .laytable-cell-2-wx_headimg, .laytable-cell-3-wx_headimg, .laytable-cell-4-wx_headimg, .laytable-cell-5-wx_headimg, .laytable-cell-6-wx_headimg, .laytable-cell-7-wx_headimg, .laytable-cell-8-wx_headimg, .laytable-cell-9-wx_headimg, .laytable-cell-10-wx_headimg, .laytable-cell-11-wx_headimg, .laytable-cell-12-wx_headimg, .laytable-cell-13-wx_headimg, .laytable-cell-14-wx_headimg {
            width: 68px !important;
            padding: 0 !important;
            height: 68px !important;
            line-height: 68px !important;
        }
    </style>
</head>
<body style="text-align:center">
<form id="friendNumberEdit" class="layui-form layui-form-pane" th:action="@{/user/friendNumber}" method="post">
    <input type="hidden" th:value="${publicUser.id}" name="id"/>
    <div class="layui-form-item ">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" name="name" th:value="${publicUser.name}" disabled />
        </div>
    </div>
    <div class="layui-form-item ">
        <label class="layui-form-label">好友数量上限</label>
        <div class="layui-input-block">
            <input type="number" min="1" max="1000" class="layui-input" name="friendNumber" th:value="${publicUser.friendNumber}" required="required"/>
        </div>
    </div>
    <div class="layui-form-item">
        <div style="margin:0 auto">
            <button class="layui-btn" type="submit">确定</button>
        </div>
    </div>
</form>

<script type="text/javascript" th:inline="javascript">

    let publicUser;
    $(function () {
        publicUser = [[${publicUser}]];
    });

    layui.use('form', function () {
        var form = layui.form;
        $("#friendNumberEdit").ajaxForm(function (success) {
            if (success.code == 200) {
                msg.success('修改成功', function () {
                    parent.window.location.reload();
                });
                // msg.success("修改成功");
                // parent.window.location.reload();
            } else {
                msg.error('修改失败', function () {
                    parent.window.location.reload();
                });
            }
        })
    });

</script>
</body>
</html>